/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package digitaldreamers.libraries.games.servers.databasemanagement.concrete;

/**
 *
 * @author DaoLe
 */
public class SqlParameter {
    // <editor-fold defaultstate="collapsed" desc="Constants">
    
    // <editor-fold defaultstate="collapsed" desc="Error messages">
    private static final String ERROR_MESSAGE__PARAMETER_NAME_IS_BLANK = "Parameter name can not be null or blank.";
    private static final String ERROR_MESSAGE__SQL_DATATYPE_IS_NULL = "SQL Datatype can not be null.";
    // </editor-fold>
    
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Parameter direction  enum">
    public static enum ParameterDirection {
        Input,
        OutPut
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="SQL datatype enum">
    public static enum SqlDataType {
        
        // Integer
        TinyInt,
        SmallInt,
        MediumInt,
        Int,
        BigInt,
        
        // Floating point
        Float,
        Double,
        
        // Decimal
        Decimal,
        
        // Date and time
        Date,
        Time,
        DateTime,
        Timestamp,
        
        // String
        Char,
        NChar,
        VarChar,
        NVarChar,
        Text,
        NText,
        
        // Binary
        Bit,
        Binary,
        VarBinary,
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Members">
    private String mParameterName;
    private ParameterDirection mDirection;
    private SqlDataType mSqlDBType;
    private Object mValue; 
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Getters/Setters">
    public String getParameterName() {
        return mParameterName;
    }
    
    public void setParameterName(String pParameterName) throws IllegalArgumentException {
        if(pParameterName == null || pParameterName.equals("")) {
            throw new IllegalArgumentException(ERROR_MESSAGE__PARAMETER_NAME_IS_BLANK);
        }
        mParameterName = pParameterName;
    }
    
    public ParameterDirection getParameterDirection() {
        return mDirection;
    }
    
    public void setParameterDirection(ParameterDirection pDirection) {
        if(pDirection == null) {
            mDirection = ParameterDirection.Input;
        }
        else {
            mDirection = pDirection;
        }
    }
    
    public SqlDataType getSqlDataType() {
        return mSqlDBType;
    }
    
    public void setSqlDataType(SqlDataType pSqlDBType) throws IllegalArgumentException {
        if(pSqlDBType == null) {
            throw new IllegalArgumentException(ERROR_MESSAGE__SQL_DATATYPE_IS_NULL);
        }
        mSqlDBType = pSqlDBType;
    }
    
    public Object getValue() {
        return mValue;
    }
    
    public void setValue(Object pValue) {
        mValue = pValue;
    }
    // </editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="Constructors">
    SqlParameter(String pParameterName, ParameterDirection pDirection, SqlDataType pSqlDBType, Object pValue) throws IllegalArgumentException {
        if(pParameterName == null || pParameterName.equals("")) {
            throw new IllegalArgumentException(ERROR_MESSAGE__PARAMETER_NAME_IS_BLANK);
        }
        if(pSqlDBType == null) {
            throw new IllegalArgumentException(ERROR_MESSAGE__SQL_DATATYPE_IS_NULL);
        }
        mParameterName = pParameterName;
        if(pDirection == null) {
            mDirection = ParameterDirection.Input;
        }
        else {
            mDirection = pDirection;
        }
        mSqlDBType = pSqlDBType;
        mValue = pValue;
    }
}